package titt.io.util.wrap;

import titt.io.socket.out.TITTOutputStream;
import titt.util.Bytes;
import titt.util.io.pipe.PipeListener;

public class StringWrapper implements Wrapper {

	@Override
	public void writeTo(PipeListener listener, TITTOutputStream out, Object o) throws Exception {
		String s = (String)o;

		out.write(Bytes.asBytes(s));		
	}
	
	@Override
	public boolean supports(Object o) {
		return o instanceof String;
	}

	@Override
	public String getMimeType(Object o) {
		return "text/html";
	}

	@Override
	public int getLength(Object o) {
		return Bytes.asBytes((String)o).length;
	}
}
